﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Collections;

public partial class Crm_visualedit : System.Web.UI.Page
{
    Dukey.Model.WebConfig mysite = BLL.WebConfig.instance.GetModelByCache();//网站配置信息
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
            DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/template/" + mysite.folder + ""));
            GetFiles(ref list, dir);
            droppage.DataSource = list;
            droppage.DataBind();
        }
    }

    private void GetFiles(ref List<KeyValuePair<string, string>> list, DirectoryInfo dir)
    {
        foreach (var item in dir.GetFiles())
        {
           
            if (!item.Attributes.ToString().Contains("Hidden") && item.Extension.ToLower().Contains(".html"))
            {
                string html = item.FullName.Replace(Server.MapPath("~/template/" + mysite.folder + "/"), "").ToString();
                string val = "/show.ashx?fn=" + html.Replace(".html", "").Replace("\\", "/");
                list.Add(new KeyValuePair<string,string>(html, val));
            }
        }
        foreach (var item in dir.GetDirectories())
        {
            GetFiles(ref list, (item as DirectoryInfo));
        }
    }

}
